<template>
  <div class="dt-content-head-query">
    <div class="dt-head-search">
      <el-input placeholder="请输入任务名称/发起人" v-model="keywords" class="input-with-select" size="mini" clearable @clear="searchAudit">
        <el-select v-model="RootProjectId" slot="prepend" placeholder="请选择">
          <el-option label="全部项目" value="0"></el-option>
          <el-option v-for="item in ProjectList" :label="item.projectName" :value="item.rootProjectId" :key="item.rootProjectId+''"></el-option>
        </el-select>
        <el-button slot="append" @click="searchAudit">搜索</el-button>
      </el-input>
    </div>
    <div class="dt-head-btn">
      <el-button type="primary" size="mini" @click="goApproval">新建审批</el-button>
    </div>
  </div>
</template>
    <script>
export default {
  data() {
    return {
      Uid: this.$tools.getDecrypt(this.$store.state.uid), //用户id,
      ProjectList: [], //项目列表
      RootProjectId: '0', //项目id
      keywords: ''
    }
  },
  methods: {
    getAllProject() {
      var data = [{ userId: this.Uid }],
        domain = [this.$store.state.DOMAIN],
        path = ['/project/project/projectSelector'],
        dataAxios = this.$tools.getDataAxios(this, domain, path, data)
      Promise.all(dataAxios)
        .then((response) => {
          this.$tools.callbackAxios(this, response, (response) => {
            var data = response[0].data
            if (data.code === 200) {
              this.ProjectList = data.data
            }
          })
        })
        .catch((error) => {})
    },
    searchAudit() {
      this.$emit('searchAudit', this.keywords, this.RootProjectId == '0' ? '' : this.RootProjectId)
    },
    onHandleClick() {
      this.keywords = ''
      this.RootProjectId = '0'
    },
    goApproval() {
      this.$emit('goApproval')
    }
  },

  mounted() {
    this.getAllProject()
  }
}
</script>
    <style scoped>
.dt-content-page {
  margin: 0;
  background-color: #f2f3f5;
}
.el-select {
  width: 280px;
}
.dt-head-search .input-with-select {
  width: 660px;
}
.dt-head-search >>> .el-input-group__append {
  background-color: #f0f5ff;
}
.dt-head-search >>> .el-button {
  color: #2f54eb;
  background-color: #f0f5ff;
  padding: 0px 20px;
}
.input-with-select >>> .el-input-group__prepend .el-input--suffix,
.input-with-select >>> .el-input__inner {
  color: #1f1f1f;
}
</style>